<template>
  <div>
    <!-- 搜索 -->
    <TopFilter ref="TopFilterss" :list="topFilterInit" :cols="2" :collapse="collapse" labelWidth="130" @filterChange="changeHandle" :isSubmitBtn="false"></TopFilter>
    <!-- table -->
<!--    <FilterTable ref="table" :columns="columns" :params="fetchParams" :isSubmitBtn="false" :dataSource="dataList" :datakey="'items'" :onColumnsChange="columns => (this.columns = columns)" :onRowSelectChange="selectChange">-->

<!--    </FilterTable>-->
    <div class="dialogBottmView">
      <!--<multiuse-button type="primary" class="btnStyle" :click="closeMenu.bind(this,1)">审核通过</multiuse-button>-->
      <!--<multiuse-button type="primary" class="btnStyle" :click="closeMenu.bind(this,1)">驳回</multiuse-button>-->
      <multiuse-button size="small" type="primary" :click="exportFileBtn.bind()">导出</multiuse-button>
      <multiuse-button type="primary" class="btnStyle" :click="coles.bind()">关闭</multiuse-button>
    </div>
  </div>
</template>
<script>
import moment from "moment";
import { getListForExportDetail} from '@/api/claim/factory/ClaimStatementQueryFactory';
import { exportExcelFile } from '@/utils/index';
import { getAppId } from '@/assets/js/auth';
import {dictionary} from'@/utils/dictMixin';
export default {
  mixins: [dictionary],
  components: {

  },
  data() {
    return {
      dataList: [],
      visible: false,
      visibleDrawer: false,
      collapse: false,
      infoId: null,
      topFilterInit: this.topFilterInitFun(),
      flterValue: {}, //参数
      columns: this.creatHeader(),
      // fetchApi: getUser,
      fetchParams: {}, //ipa 接口
      selectedRows: [], //选中服务站
      dialogTitle: '选择车辆',
      visibleAdd: false,

    };
  },
  created() {
    // this.dataList = [...res.data.items];
    this.fetchParams.statementGenerationTimeStar = moment().startOf('week').format('YYYY-MM-DD HH:mm:ss');
    this.fetchParams.statementGenerationTimeEnd = moment().endOf('week').format('YYYY-MM-DD HH:mm:ss');
    console.log(this.dataList);
    if(getAppId()=='beijing'){
      this.topFilterInit.find((x) => x.fieldName == 'ifComm').itemList = this.createDictList('5543');
    }else{
      this.topFilterInit.find((x) => x.fieldName == 'ifComm').itemList = this.createDictList('5543');
      this.topFilterInit.find((x) => x.fieldName == 'ifComm').initialValue = 55431002;
      this.topFilterInit.find((x) => x.fieldName == 'ifComm').disabled=true;
      
    }
  },
  methods: {
    //搜索数据
    topFilterInitFun() {
      return [
        { type: 'RANGE_DATE', label: '索赔单审核时间', fieldName: 'claimFormCreationTimeStart|claimFormCreationTimeEnd', placeholder: '请输入', initialValue: '' },
        { type: 'RANGE_DATE', label: '结算单生成时间', fieldName: 'statementGenerationTimeStar|statementGenerationTimeEnd', placeholder: '请输入',initialValue:''},
        { type: 'RANGE_DATE', label: '服务站发票邮寄时间', fieldName: 'invoiceMailingTimeStar|invoiceMailingTimeEnd', placeholder: '请输入', initialValue: '' },
        { type: 'RANGE_DATE', label: '发票到达时间', fieldName: 'invoiceReviewTimeStar|invoiceReviewTimeEnd', placeholder: '请输入', initialValue: '' },
        {type: 'INPUT', label: '结算汇总单号', fieldName: 'sumNo', placeholder: '请输入结算汇总单号...', initialValue: ''},
        {
          type: 'SELECT',
          label: '索赔车辆属性',
          fieldName: 'ifComm',
          placeholder: '请选择索赔车辆属性...',
          initialValue: '',
          itemList:[],
          filterable:true
        },
      ];
    },
    //搜索获取数据
    changeHandle(val) {
      this.fetchParams = val;
      console.log(val);
    },
    //table表头和数据源
    creatHeader() {
      return [

      ];
    },
    //选中
    selectChange(rows) {
      this.selectedRows = rows;
      console.log(this.selectedRows);
    },
    close(){
      this.visible = false;
    },
    chooseOrderNo() {
      this.visible = true;
    },
    save(obj) {
      this.topFilterInit.find(x => x.fieldName == 'model').initialValue = obj[0].address;
      this.visible = false;
    },
    exportFileBtn() {
      let data = this.$refs.TopFilterss.SUBMIT_FORM();
      let beginSubmitDate = data.statementGenerationTimeStar;
      let endSubmitDate = data.statementGenerationTimeEnd;
      if(!beginSubmitDate) {
        this.$notify.warning({ title: '提示信息', message: '开票开始日期不可为空！' });
        return
      }
      if(!endSubmitDate) {
        this.$notify.warning({ title: '提示信息', message: '开票结束日期不可为空！' });
        return
      }
        if (moment(moment(endSubmitDate).format('YYYY-MM-DD')).diff(moment(beginSubmitDate), 'months', true) > 12) {
          this.$notify.warning({ title: '提示信息', message: '开票日期跨度不可超过十二个月！' });
          return
        }
      getListForExportDetail(data).then((res) => {
        console.log(res,"123");
        exportExcelFile(res.data, '导出明细');
      });
    },
    add() {
      this.visibleAdd = true;
    },

    closeAdd() {
      this.visibleAdd = false;
      this.fetchParams = { ...this.fetchParams };
    },
    saveAdd() {
      this.visibleAdd = false;
      this.fetchParams = { ...this.fetchParams };
    },

    coles()
    {
      this.$emit('close');
    },
  }
};
</script>

<style lang="less" scoped></style>
